package edu.gatech.volt2.drdoommgt.domain;

import java.util.Calendar;

import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

/**
 * This class creates a treatment record of the patient for each appointment
 * 
 * @author Khalen Morehead
 */
@Entity
@Table(name="treatment_records")
public class TreatmentRecord 
{
	@Id
	@GeneratedValue(generator="increment")
	@GenericGenerator(name="increment", strategy = "increment")
	private long id;
	@Embedded
	private VitalSigns vital;
	@ManyToOne(cascade = CascadeType.PERSIST)
	private DocOrder docOrders;
	@ManyToOne(cascade = CascadeType.PERSIST)
	private Doctor treatingDoc;
	@ManyToOne(cascade = CascadeType.PERSIST)
	private Nurse nurse;
	private String complaint;
	private String diagnosis;
	private String notes;
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar date;
	
	
	/**
	 * Default constructor
	 */
	public TreatmentRecord()
	{
		this.vital = new VitalSigns();
		this.docOrders = new DocOrder();
		this.treatingDoc = new Doctor();
		this.nurse = new Nurse();
		this.complaint = "N/A";
		this.diagnosis = "N/A";
		this.date= Calendar.getInstance();
		//this.date = null; if we set it to NULL
	}
	
	/**
	 * Constructor that takes in passed in objects
	 * @param vital Vital signs
	 * @param docOrders Doctor's orders
	 * @param treatingDoc Doctor treating the patient
	 * @param nurse Nurse assisting the doctor
	 * @param complaint Patient's problem
	 * @param diagnosis Doctor's diagnosis
	 */
	public TreatmentRecord(VitalSigns vital, DocOrder docOrders, 
			Doctor treatingDoc, Nurse nurse, String complaint, 
			String diagnosis)
	{
		this.vital = vital;
		this.docOrders = docOrders;
		this.treatingDoc = treatingDoc;
		this.nurse = nurse;
		this.complaint = complaint;
		this.diagnosis = diagnosis;
		this.date = Calendar.getInstance();
	}
	
	/**
	 * Concatenates string of class info 
	 * @return string of class info
	 */
	public String toString()
	{
		return "Vitals: " + vital + "\nDoctor's Orders: " + docOrders + 
		"\nTreating Doctor: " + treatingDoc + "\nAttending Nurse: " + nurse + 
		"\nPatient Complaint: " + complaint + "\nDiagnosis: " + diagnosis;
	}
	
	/**
	 * @param date the date to set
	 */
	public void setDate(Calendar date) {
		this.date = date;
	}

	/**
	 * @return the date
	 */
	public Calendar getDate() {
		return date;
	}

	/**
	 * Vital getter
	 * @return vital Vital signs
	 */
	public VitalSigns getVital()
	{
		return vital;
	}
	
	/**
	 * Vital setter
	 * @param vital Vital signs
	 */
	public void setVital(VitalSigns vital)
	{
		this.vital=vital;
	}

	/**
	 * DocOrders getter
	 * @return docOrders Doctor's orders
	 */
	public DocOrder getDocOrders()
	{
		return docOrders;
	}

	/**
	 * DocOrders setter
	 * @param docOrders Doc's orders
	 */
	public void setDocOrders(DocOrder docOrders)
	{
		this.docOrders=docOrders;
	}

	/**
	 * Treating doctor getter
	 * @return treatingDoc Treating doctor
	 */
	public Doctor getTreatingDoc()
	{
		return treatingDoc;
	}

	/**
	 * Treating doctor setter
	 * @param treatingDoc Attending doc
	 */
	public void setTreatingDoc(Doctor treatingDoc)
	{
		this.treatingDoc=treatingDoc;
	}

	/**
	 * Nurse getter
	 * @return nurse Assisting nurse
	 */
	public Nurse getNurse()
	{
		return nurse;
	}

	/**
	 * Nurse setter 
	 * @param nurse Assiting nurse
	 */
	public void setNurse(Nurse nurse)
	{
		this.nurse=nurse;
	}

	/**
	 * Complaint getter
	 * @return complaint Patient's complaint
	 */
	public String getComplaint()
	{
		return complaint;
	}

	/**
	 * Complaint setter
	 * @param complaint Patient's complaint
	 */
	public void setComplaint(String complaint)
	{
		this.complaint=complaint;
	}

	/**
	 *  Diagnosis getter
	 * @return diagnosis Doc's diagnosis
	 */
	public String getDiagnosis()
	{
		return diagnosis;
	}

	/**
	 * Diagnosis setter
	 * @param diagnosis Doc's diagnosis
	 */
	public void setDiagnosis(String diagnosis)
	{
		this.diagnosis=diagnosis;
	}

	/**
	 * @param notes the notes to set
	 */
	public void setNotes(String notes) {
		this.notes = notes;
	}

	/**
	 * @return the notes
	 */
	public String getNotes() {
		return notes;
	}
}
